﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GUIScript : MonoBehaviour {

    public Button pause;
    public Button resume;

    public GameObject PauseMenu;
    public GameObject GamePlay;

    public string message = "";
    public Button[] allcomponents;

	void Start ()
    {
        pause.ButtonClick += pause_ButtonClick;
        resume.ButtonClick += resume_ButtonClick;
        if (allcomponents.Length > 3)
        {
            allcomponents[0].ButtonClick += GUIScript_ButtonClick;          
        }
	}

    void GUIScript_ButtonClick()
    {
        Application.LoadLevel("MainMenu");
    }

    void resume_ButtonClick()
    {
        message = "no press";
        Time.timeScale = 1;
        PauseMenu.SetActive(false);
        GamePlay.SetActive(true);
    }

    void pause_ButtonClick()
    {
        message = "press";
        Time.timeScale = 0;
        PauseMenu.SetActive(true);
        GamePlay.SetActive(false);       
        allcomponents = PauseMenu.GetComponentsInChildren<Button>();  
    }
	

	void Update () 
    {      
        
	}
}
